package com.jishuo.nontax.bfc.service;

import com.github.pagehelper.PageHelper;
import com.jishuo.base.bean.BaseResult;
import com.jishuo.base.bean.ErrorCodeEnum;
import com.jishuo.base.bean.Pagination;
import com.jishuo.base.service.SequenceService;
import com.jishuo.nontax.bean.message.GetStatData;
import com.jishuo.nontax.bean.message.GetStatData1;
import com.jishuo.nontax.bean.vo.BankCheckBillVO;
import com.jishuo.nontax.bean.vo.StatDataVO;
import com.jishuo.nontax.bfc.dao.MessageSysMapper;
import com.jishuo.nontax.bfc.dao.StatDataMapper;
import com.jishuo.nontax.bfc.tlq.MessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author :hanlipeng
 * @description :
 * @create :2022-12-21 13:59:00
 */
@Service
public class StatDataService {
    private static Logger logger = LoggerFactory.getLogger(StatDataService.class);
    @Resource
    private SequenceService sequenceService;
    @Resource
    private StatDataMapper statDataMapper;
    @Resource
    private MessageService messageService;


    public BaseResult getStatData(Long cantonid, String paybankdt) {

        try {
            long messageid = sequenceService.getNextSeq("ELEMESSAGESEQ");
            GetStatData stat= new GetStatData();
            stat.setCantonid(cantonid.intValue());
            stat.setPaybankdt(paybankdt);

            messageService.sendMessage("GETSTATDATA", messageid, stat, "2.3");

            return new BaseResult();

        } catch (Exception e) {
            logger.info("处理获取区划月度分析失败：" + e.toString());
            return new BaseResult();
        }
    }


    public BaseResult getStatData1(Long cantonid, String paybankdt) {

        try {
            long messageid = sequenceService.getNextSeq("ELEMESSAGESEQ");

            GetStatData1 stat1= new GetStatData1();
            stat1.setCantonid(cantonid.intValue());
            stat1.setPaybankdt(paybankdt);

            messageService.sendMessage("GETSTATDATA1", messageid, stat1, "2.3");

            return new BaseResult();
        } catch (Exception e) {
            logger.info("处理获取区划月度分析失败：" + e.toString());
            return new BaseResult(ErrorCodeEnum.UNKNOWN_ERR);
        }
    }

    // 页面

    /**
     * 区划月度分析列表
     * @param cantonid  区域id
     * @param paybankdt   精确到月份
     * @return
     */
    public List<StatDataVO> findStatDataPage(Long cantonid, String paybankdt, Pagination pagination) {
        // 当单页条数大于零时，启用分页
        if (pagination.getRows() > 0) PageHelper.startPage(pagination.getPage(), pagination.getRows());
        return this.statDataMapper.findStatData(cantonid,paybankdt);
    }

    /**
     * 业务类型月度分析列表
     * @param cantonid  区域id
     * @param paybankdt   精确到月份
     * @return
     */
    public List<StatDataVO> findStatDataTwoPage(Long cantonid, String paybankdt, Pagination pagination) {
        // 当单页条数大于零时，启用分页
        if (pagination.getRows() > 0) PageHelper.startPage(pagination.getPage(), pagination.getRows());
        return this.statDataMapper.findStatDataTwo(cantonid,paybankdt);
    }

}
